/*显示 tooltip 
 */

var className = "toolTip-box";

var getDocID = function(id) {
	return document.getElementById(id);
}

function showToolTlip(obj, id, html, width, height) {

	if (document.getElementById(id) == null) {

		var tooltipBox;
		tooltipBox = document.createElement("div");
		tooltipBox.className = className;
		tooltipBox.id = id;
		tooltipBox.innerHTML = html;

		obj.appendChild(tooltipBox);

		tooltipBox.style.width = width ? width + "px" : "auto";
		tooltipBox.style.height = height ? height + "px" : "auto";

		tooltipBox.style.position = "absolute";
		tooltipBox.style.display = "block";

		var left = obj.offsetLeft;
		var top = obj.offsetTop + 20;

		tooltipBox.style.left = left + "px";
		tooltipBox.style.top = tooltipBox + "px";
		
		obj.addEventListener("mouseout",function(){
			setTimeout(function(){
				getDocID(id).style.display = "none";
			});
		});
		/*obj.onmouseout = function() {
			//	document.getElementById(id).style.display = "none";
			setTimeout(function() {
				getDocID.style.display = 　"none";
			},500);
		}*/

	} else {
		//document.getElementById(id).style.display = "block";
		getDocID(id).style.display = "block";

	}
}
/*
var wb = document.getElementById("weibo");
var wx = document.getElementById("weixin");
var lg = document.getElementById("logo");
var tx = document.getElementById("taoxue");
*/
var wb = getDocID("weibo");
var wx = getDocID("weixin");
var lg = getDocID("logo");
var tx = getDocID("taoxue");
wb.onmouseover = function() {
	showToolTlip(this, "wb", "淘学网", 150);
}
wx.onmouseover = function() {
	showToolTlip(this, "wx", "淘学网", 150);
}
lg.onmouseover = function() {
	showToolTlip(this, "lg", "<img src='img/1.jpg'>", 200);
}
tx.onmouseover = function() {
	var taobao = "<iframe src='http://www.taobao.com' width='500' height='300'></iframe";
	showToolTlip(this, "tx", taobao, 150);
}